package com.woniu.strategy;


import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
public enum CodeEnum {

    USER("user"),
    AGE("age"),
    INTEREST("interest"),
    ;

    private final String code;

    CodeEnum(String code) {
        this.code = code;
    }

    private static final Map<String, CodeEnum> map = Arrays.stream(CodeEnum.values())
            .collect(Collectors.toMap(CodeEnum::getCode, Function.identity()));


    public static CodeEnum of(String code) {
        return map.get(code);
    }


}
